//
//  HomeInfoView.m
//  Ginix
//
//  Created by 冯志强 on 2025/2/20.
//

#import "HomeInfoView.h"
#import "HomeInfoSleepView.h"
#import "HomeInfoDataView.h"

@interface HomeInfoView()

@property (nonatomic,strong) HomeInfoSleepView * sleepView;
@property (nonatomic,strong) HomeInfoDataView * dataView;

@end

@implementation HomeInfoView

-(instancetype)initWithFrame:(CGRect)frame{
    
    if (self = [super initWithFrame:frame]) {
        [self setSubViewLayout];
    }
    return self;
}

-(void)setSubViewLayout{
    
    self.backgroundColor = RDRGB(0xF5F2ED);
    [self addSubview:self.sleepView];

    [_sleepView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_offset(CGSizeMake(345 * FMScaleX, 110 * FMScaleX));
        make.centerX.equalTo(@0);
        make.top.mas_offset(0 * FMScaleX);
    }];
    [self addSubview:self.dataView];
    [_dataView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(@0);
        make.size.mas_offset(CGSizeMake(WIDTH, 54 * FMScaleX));
        make.top.equalTo(self.sleepView.mas_bottom).offset(0 * FMScaleX);
    }];
    if (ISUPDATE) {
        self.dataView.hidden = YES;
    }
}

-(void)setInfoModel:(HomeSleepModel *)infoModel{
    
    [self.sleepView setInfoModel:infoModel];
    [self.dataView setInfoModel:infoModel];
}

-(HomeInfoSleepView *)sleepView{
    
    if (!_sleepView) {
        _sleepView = [[HomeInfoSleepView alloc]init];
    }
    return _sleepView;
}

-(HomeInfoDataView *)dataView{
    
    if (!_dataView) {
        _dataView = [[HomeInfoDataView alloc]init];
    }
    return _dataView;
}

@end
